/**
 * Created by Administrator on 2017/11/17.
 */
import React, {Component} from 'react';
import {Form, Row, Input, Button,Switch,Select} from 'antd';
const FormItem = Form.Item;
const Option = Select.Option;
import {injectIntl} from 'react-intl';
@injectIntl
class SearchForm extends Component {
  constructor(props) {
    super(props);
  }
  handleSubmit = (e) => {
    e.preventDefault();
    const {dispatch, form} = this.props;
    form.validateFields((err, fieldsValue) => {
      if (err) return;
      const values = {
        ...fieldsValue,
      };
      this.props.handleSearch({...values, page: 1, per_page: this.props.per_page})
    });
  }
  render() {
    const {intl:{formatMessage}} = this.props;
    const {getFieldDecorator} = this.props.form;
    return (
      <Form onSubmit={this.handleSubmit} layout="inline">

        <Row >
          <FormItem
            label={(
              <span>
            是否已安装
            </span>
            )}
          >
            {getFieldDecorator('installed', {
            })(
              <Select style={{width:'100px'}}>
                <Option value={''}>全部</Option>
                <Option value={'1'}>已安装</Option>
                <Option value={'-1'}>未安装</Option>
              </Select>
            )}
          </FormItem>
          <FormItem >
            <Button type="primary" htmlType="submit"> {formatMessage({id: 'intl.search'})}</Button>
          </FormItem>
         <FormItem   >
            <Button type="primary" onClick={this.props.clickAdd} icon='plus'>{formatMessage({id: 'intl.add'})}</Button>
          </FormItem>

          <FormItem  label={formatMessage({id: 'intl.open_operating_bar'})}  style={{float:'right'}}  className="openOperate">
            <Switch defaultChecked={localStorage.getItem('workstations')==='true'?true:false} onChange={(checked)=>{
              localStorage.setItem('workstations',checked);
              this.props.changeShowOperate()
            }} />
          </FormItem>
        </Row>

      </Form>
    )
  }
}
const DefaultSearch = Form.create()(SearchForm);
export default DefaultSearch;
